package onetotwenty;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import org.junit.Test;

public class ProblemFive {
	private long gcd(long p, long q) {
		if (q == 0)
			return p;
		return gcd(q, p % q);
	}

	private long lcm(long p, long q) {
		return (p * q) / gcd(p, q);
	}

	private long answer(int n) {
		long item = 2;
		for(int i=3;i<=n;i++) {
			item = lcm(item, i);
		}
		
		return item;
	}

	@Test
	public void test10() {
		assertThat(answer(10), is(2520L));
	}

	@Test
	public void printAnswer() {
		assertThat(answer(20), is(232792560L));
	}
}
